#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int Maxn=3e5+7;
int T;
int n,a[Maxn];

struct Seg{
	ll l,r;
}f[Maxn];
vector<int>e[Maxn];

bool tag;
void dfs(int u,int ft){
	
	f[u].l=f[u].r=a[u];
	ll ret1=0,ret2=0;
	int lp=0;
	for(auto v:e[u]){
		if(v!=ft){
			lp++;
			dfs(v,u);
			ret1+=f[v].l;
			ret2+=f[v].r;
		}
	}
//	cout<<f[u].l<<" "<<f[u].r<<endl;
	if(lp){
		
		f[u].r=ret2;
		f[u].l=(ret1+1)/2;
//		cout<<u<<" "<<f[u].l<<" "<<f[u].r<<" "<<endl;
		if(f[u].l<=a[u] and a[u]<=f[u].r){
			if(f[u].l%2==1) tag=0;
		}
		else tag=0;
	}
	

	
}

int main(){
	freopen("clean.in","r",stdin);
	freopen("clean.out","w",stdout);
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);
		for(int i=1;i<=n;i++) scanf("%d",&a[i]);
		for(int i=1;i<=n;i++) f[i].l=f[i].r=0;
		for(int i=1;i<=n;i++) e[i].resize(0);
		for(int i=1;i<n;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			e[u].emplace_back(v);
			e[v].emplace_back(u);
		}
		tag=1;
		dfs(1,0);
//		if(f[1].l!=0) tag=0;

		if(tag) puts("YES");
		else puts("NO");
		
	}
	return 0;
}
/*
1
5
1 2 1 1 2
2 4
5 2
3 2
1 3

1
3
1 2 1
1 2
2 3
*/
